// 提现记录

const { Schema, SchemaTypes } = require('../schema');
const timeTool = require('../../module/tool/time');
class WithdrawRecord extends Schema {
    PropertyModelDataTemplate () {
        return {
            areaId: {
                type: SchemaTypes.ObjectId,
                required: true
            },
            // 操作者
            adminId: {
                type: SchemaTypes.ObjectId,
                required: true
            },
            // 扣除金额
            price: {
                type: SchemaTypes.Number,
                required: true
            },
            // 实际打款金额
            realPrice: {
                type: SchemaTypes.Number,
                required: false
            },
            description: {
                type: SchemaTypes.String,
                required: false
            },
            createTime: {
                type: SchemaTypes.Number,
                required: true,
                default: timeTool.getCurrentTimestamp()
            }
        };
    }

    async initWithdrawRecord (adminId, areaId, price, realPrice, description) {
        return this.getDoc({
            areaId: areaId,
            adminId: adminId,
            price: price,
            realPrice: realPrice,
            description: description
        }).save();
    }
}

module.exports = WithdrawRecord;
